-- First we'll make sure that Jon's Commands is actually in the Scripting Additions folder.
-- We'll put the path to the System folder in a variable called sysPath.
path to system folder
set sysPath to the result
set jonAvail to "false"
-- Next we'll look in the Scripting Additions folder, inside the Extensions folder.
try
select file "Jon’s Commands" of folder "Scripting Additions" of folder "Extensions" of sysPath
set jonAvail to "true"
on error
set jonAvail to "false"
end try
-- Next we'll look in the Scripting Additions folder, System Folder.
if jonAvail = "false" then
try
select file "Jon’s Commands" of folder "Scripting Additions" of sysPath
set jonAvail to "true"
on error
set jonAvail to "false"
end try
end if
-- Now we'll inform the user if they don't have it available.
if jonAvail = "false" then
display dialog ¬
"Could not find Jon's Commands in the Scripting Additions folder. Please put it there and restart your computer to use this applet." buttons {"Ok"} default button 1 ¬
giving up after 30
return
end if
-- Now Jon's Commands does the work of erasing the Desktop DB & DF files.
try
set the diskName to the name of the startup disk
{diskName, ":Trash:"} as string
-- I left the result commands in as a debugging function. Makes no difference tot he end user.
result
set the trashPath to the result
{diskName, ":Desktop DB"} as string
result
set dbPath to the result
{diskName, ":Desktop DF"} as string
result
set dfPath to the result
moveFile alias dbPath to alias trashPath
moveFile alias dfPath to alias trashPath
-- Display a dialog box informing the user that an error has occurred. This is a timed dialog box which will go away after 20 seconds.
display dialog ¬
"The Desktop DB and Desktop DF files were successfully moved to the trash. You should now restart your computer." buttons {"Restart", "Shutdown", "Continue"} default button 3 ¬
giving up after 30
-- Put the results of the button push in a variable called button_pressed
set the button_pressed to the button returned of the result
-- If restart
if the button_pressed is "Restart" then
restart
end if
-- If shutdown
if the button_pressed is "Shutdown" then
shutdown
end if
-- If continue
if the button_pressed is "Continue" then
return
end if
on error
-- Display a dialog box informing the user that an error has occurred. This is a timed dialog box which will go away after 20 seconds.
display dialog ¬
"Oops! Desktop Purger couldn't move the Desktop DB and Desktop DF files to the trash. They may already be in the trash. Also, make sure you restarted your Macintosh after putting the Jon's Commands in the Scripting Additions folder." buttons {"Ok"} default button 1 ¬